<template>
  <div class="define_aside">
    <div class="define_header">
      <i class="el-icon-menu"></i>{{ $t("flowDefine.form.flowType.title") }}
    </div>
    <div class="define_content">
      <el-tree
        :data="treeData"
        @node-click="changeFlowType"
        node-key="id"
        :props="defaultProps"
      >
      </el-tree>
    </div>
  </div>
</template>

<script>
import { mapActions, mapState } from "vuex";
import { listClassify } from "@/api/flowClassifyApi";
export default {
  name: "define_aside",
  data() {
    return {
      defaultProps: {
        children: "children",
        label: "name",
      },
      treeData:[]
    };
  },
  methods: {
    ...mapActions("flowDesignStore", ["getFlowList"]),
    async changeFlowType(item) {
      this.$store.state.flowDesignStore.form.flowType = item.id;
      const rst = await this.getFlowList({
        params: {
          pageNum: 1,
          pageSize: 10,
        },
        data: {
          flowType: item.id,
          flowName: this.$store.state.flowDesignStore.form.flowName,
        },
      });
      console.log(rst,'resresres');
      this.$store.state.flowDesignStore.flowListData=rst.data.records
      this.$store.state.flowDesignStore.total=rst.data.total
      // this._info(rst, {
      //   success: [
      //     this.$t("flowTask.flowData", [
      //       this.$t("button.search"),
      //       this.$t("flowDefine.title"),
      //     ]),
      //   ],
      //   error: [this.$t("flowTask.flowData")],
      // });
    },
    // ...mapActions("flowClassifyStore", ["getFlowList"]),
    // ...mapActions("flowDefineStore", ["getFlowDefineList"]),
  },
   mounted() {
    listClassify().then((res) => {
      this.treeData = res.data.data;
    });
  },
};
</script>

<style lang="scss" scoped>
.define_aside {
  padding-right: 10px;
  margin-right: 10px;
  width: 250px;
  overflow: auto;
  .define_header {
    border-bottom: 1px solid #eee;
    height: 40px;
    width: 100%;
    line-height: 40px;
    & i {
      color: #3e70dd;
      padding: 0 5px;
    }
  }
  .define_content {
    overflow: auto;
  }
}
</style>
